<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: String
  
    &mdash; FSelector Documentation
  
</title>

  <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />

  <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  relpath = '';
  if (relpath != '') relpath += '/';
</script>

  <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="js/app.js"></script>


  </head>
  <body>
    <script type="text/javascript" charset="utf-8">
      if (window.top.frames.main) document.body.className = 'frames';
    </script>
    
    <div id="header">
      <div id="menu">
  
    <a href="_index.html">Index (S)</a> &raquo; 
    
    
    <span class="title">String</span>
  
  
  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a id="class_list_link" href="#">Class List</a>
  
    <a id="method_list_link" href="#">Method List</a>
  
    <a id="file_list_link" href="#">File List</a>
  
</div>
      <div class="clear"></div>
    </div>
    
    <iframe id="search_frame"></iframe>
    
    <div id="content"><h1>Class: String
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">String</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
  
  
  
    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/fselector/util.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    <p>add functions to String class</p>


  </div>
</div>
<div class="tags">
  

</div>






  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#blank%3F-instance_method" title="#blank? (instance method)">- (Boolean) <strong>blank?</strong> </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>blank line?.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#comment%3F-instance_method" title="#comment? (instance method)">- (Boolean) <strong>comment?</strong>(char = '#') </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>comment line?.</p>
</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#split_me-instance_method" title="#split_me (instance method)">- (Array&lt;String&gt;) <strong>split_me</strong>(delim_regex, quote_char = &quot;'&quot;) </a>
    

    
  </span>
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'><p>Enhanced String.split with escape char, which means
string included in a pair of escape char is considered as a whole
even if it matches the split regular expression.</p>
</div></span>
  
</li>

      
    </ul>
  



  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>
    
    
      <div class="method_details first">
  <p class="signature first" id="blank?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>blank?</strong> 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>blank line?</p>


  </div>
</div>
<div class="tags">
  
<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


132
133
134</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 132</span>

<span class='kw'>def</span> <span class='id identifier rubyid_blank?'>blank?</span>
  <span class='kw'>return</span> <span class='kw'>self</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^\s*$</span><span class='regexp_end'>/</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="comment?-instance_method">
  
    - (<tt>Boolean</tt>) <strong>comment?</strong>(char = '#') 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>comment line?</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>char</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="String (class)">String</a></span></tt>)</span>
      
      
        <em class="default">(defaults to: <tt>'#'</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>line beginning char</p>
</div>
      
    </li>
  
</ul>

<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt>Boolean</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


126
127
128</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 126</span>

<span class='kw'>def</span> <span class='id identifier rubyid_comment?'>comment?</span><span class='lparen'>(</span><span class='id identifier rubyid_char'>char</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>#</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
  <span class='kw'>return</span> <span class='kw'>self</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_char'>char</span><span class='rbrace'>}</span><span class='regexp_end'>/</span></span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <p class="signature " id="split_me-instance_method">
  
    - (<tt><span class='object_link'><a href="Array.html" title="Array (class)">Array</a></span>&lt;<span class='object_link'><a href="" title="String (class)">String</a></span>&gt;</tt>) <strong>split_me</strong>(delim_regex, quote_char = &quot;'&quot;) 
  

  
</p><div class="docstring">
  <div class="discussion">
    <p>Enhanced String.split with escape char, which means
string included in a pair of escape char is considered as a whole
even if it matches the split regular expression. this is especially
useful to parse CSV file that contains comma in a doube-quoted string
e.g. &#39;a,&quot;b, c&quot;,d&#39;.split_me(/,/, &#39;&quot;&#39;) =&gt; [a, &#39;b, c&#39;, d]</p>


  </div>
</div>
<div class="tags">
  <h3>Parameters:</h3>
<ul class="param">
  
    <li>
      
        <span class='name'>delim_regex</span>
      
      
        <span class='type'>(<tt>Regex</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'><p>regular expression for split</p>
</div>
      
    </li>
  
    <li>
      
        <span class='name'>quote_char</span>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="" title="String (class)">String</a></span></tt>)</span>
      
      
        <em class="default">(defaults to: <tt>&quot;'&quot;</tt>)</em>
      
      
        &mdash;
        <div class='inline'><p>quote char such as &#39; and &quot;</p>
</div>
      
    </li>
  
</ul>

<h3>Returns:</h3>
<ul class="return">
  
    <li>
      
      
        <span class='type'>(<tt><span class='object_link'><a href="Array.html" title="Array (class)">Array</a></span>&lt;<span class='object_link'><a href="" title="String (class)">String</a></span>&gt;</tt>)</span>
      
      
      
    </li>
  
</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


148
149
150
151
152
153
154
155</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/fselector/util.rb', line 148</span>

<span class='kw'>def</span> <span class='id identifier rubyid_split_me'>split_me</span><span class='lparen'>(</span><span class='id identifier rubyid_delim_regex'>delim_regex</span><span class='comma'>,</span> <span class='id identifier rubyid_quote_char'>quote_char</span><span class='op'>=</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>'</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
  <span class='id identifier rubyid_d'>d</span><span class='comma'>,</span> <span class='id identifier rubyid_q'>q</span> <span class='op'>=</span> <span class='id identifier rubyid_delim_regex'>delim_regex</span><span class='comma'>,</span> <span class='id identifier rubyid_quote_char'>quote_char</span>
  <span class='kw'>if</span> <span class='kw'>not</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_q'>q</span><span class='rparen'>)</span> <span class='op'>%</span> <span class='int'>2</span> <span class='op'>==</span> <span class='int'>0</span>
    <span class='gvar'>$stderr</span><span class='period'>.</span><span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>unpaired char of </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_q'>q</span><span class='rbrace'>}</span><span class='tstring_content'> found, return nil</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>return</span> <span class='kw'>nil</span>
  <span class='kw'>end</span>
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_d'>d</span><span class='period'>.</span><span class='id identifier rubyid_source'>source</span><span class='rbrace'>}</span><span class='tstring_content'> (?=(?:[^</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_q'>q</span><span class='rbrace'>}</span><span class='tstring_content'>]* </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_q'>q</span><span class='rbrace'>}</span><span class='tstring_content'> [^</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_q'>q</span><span class='rbrace'>}</span><span class='tstring_content'>]* </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_q'>q</span><span class='rbrace'>}</span><span class='tstring_content'>)* [^</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_q'>q</span><span class='rbrace'>}</span><span class='tstring_content'>]*$) </span><span class='regexp_end'>/x</span></span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>
    
    <div id="footer">
  Generated on Mon Nov  5 11:19:44 2012 by 
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.7.5 (ruby-1.9.3).
</div>

  </body>
</html>